<%--
  Created by IntelliJ IDEA.
  User: Acer
  Date: 2020/9/13
  Time: 10:28
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="rapid" uri="http://www.rapid-framework.org.cn/rapid" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<rapid:override name="head">
    <title>我的选课</title>
</rapid:override>

<rapid:override name="content">
    <%
        String path = request.getContextPath();
        String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
    %>

    <div class="layui-form" style="width: 900px;margin: auto" >
        <table class="layui-table">
            <thead>
            <tr>
                <th>课程编号</th>
                <th>课程名称</th>
                <th>教师名称</th>
                <th>人数限制</th>
                <th>已选人数</th>
                <th>分数</th>
                <th>操作</th>
            </tr>
            </thead>
            <tbody>

                <c:forEach items="${courseList}" var="course">
                    <tr>
                        <td>${course.classId}</td>
                        <td>${course.className}</td>
                        <td>${course.teaName}</td>
                        <td>${course.classNum}</td>
                        <td>${course.classChooseNum}</td>
                        <td>${course.score}</td>
                        <td>
                            <button type="button" class="layui-btn" onclick="deleteCourse(${course.classId})">退课</button>
                        </td>
                    </tr>
                </c:forEach>

            </tbody>
        </table>
    </div>


    <script>
        function deleteCourse(classId) {
            let r = confirm("你确定要退课吗？");
            if(r == true) {
                // 当前页面打开新的页面 -- 包括传递的数据
                window.location.href="<%=basePath%>/student/deleteCourse?classId="+classId;
            } else {
                return ;
            }
        }
    </script>
</rapid:override>

<%@include file="base.jsp"%>